<!-- Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT License. -->
<!DOCTYPE html>
<html>

<head>
    <!-- Office JavaScript API -->
    <script type="text/javascript" src="https://appsforoffice.microsoft.com/lib/1/hosted/office.js"></script>
</head>

<body>
    <p>This add-in will insert 'Hello world!' in the current selection of the slide.</p>
    <button id="helloButton">Say hello</button>

    <!-- The following image URL tracks diagnostic data for this sample add-in. Please remove the image tag if you reuse this sample in your own code project. -->
    <img src="https://pnptelemetry.azurewebsites.net/pnp-officeaddins/samples/powerpoint-add-in-hello-world-run" />
</body>

<script>
    Office.onReady((info) => {
        // Check that we loaded into PowerPoint
        if (info.host === Office.HostType.PowerPoint) {
            document.getElementById("helloButton").onclick = sayHello;
        }
    });

    async function sayHello() {

        // Set coercion type to text since 
        const options = { coercionType: Office.CoercionType.Text };

        // clear current selection
        await Office.context.document.setSelectedDataAsync(" ", options);

        // Set text in selection to 'Hello world!'
        await Office.context.document.setSelectedDataAsync("Hello world!", options);
    }

</script>

</html>